package com.pacyki.adapters;

import java.util.ArrayList;

import com.helpfuctions.gcards.Contact;
import com.pacyki.gcards.R;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class AddedContactsAdapter extends BaseAdapter{

	private ArrayList<Contact> mContactList;
	private Context mContext;
	private LayoutInflater layoutInflater;
	private View mCurrentView;
	
	public AddedContactsAdapter(Context context, ArrayList<Contact> contactsList) {
		mContactList = contactsList;
		mContext = context;
		layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	@Override
	public int getCount() {
		return mContactList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View currentView, ViewGroup root) {
		mCurrentView = layoutInflater.inflate(R.layout.contacts_list_item, null);
		ImageView imageView = (ImageView) mCurrentView.findViewById(R.id.photoImageView);
		Button deleteButton = (Button) mCurrentView.findViewById(R.id.deleteContactButton);
		TextView mailTextView = (TextView) mCurrentView.findViewById(R.id.mailTextView);
		TextView nameTextView = (TextView) mCurrentView.findViewById(R.id.nameTextView);
		
		ListView.LayoutParams layoutParams = new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT, 100);
		mCurrentView.setLayoutParams(layoutParams);
		
		Contact contact = mContactList.get(position);
		mailTextView.setText("Mail: " + contact.getMail());
		nameTextView.setText("Name: " + contact.getName());
		imageView.setImageBitmap(contact.getImage());
		return mCurrentView;
	}

}
